<template>
 <transition name="slide">
  <div class="home-container">
    <P class="page-title">
      <span @click="back" class="mint-button-icon"><i class="mintui mintui-back" style="font-size:1.4rem"></i></span>
        {{album_name}}
        </P>
    <div class="album-container">
        <div class="album-item" v-for="(photo,index) in photoList" :key="index">
            <img class="album-face"  v-lazy="photo.compress_url" alt="">
            <p class="album-name">{{photo.photo_name}}</p>
            <!-- {{album.id}} -->
        </div>
        <div class="plac-album" v-for="(album,index) in photoList">

        </div>
    </div>
  </div>
  </transition>
</template>


<script>
export default {
  name: 'Photo',
  data() {
    return {
      album_name: '',
      username: '',
      photoList: []
    };
  },
  created() {
    this.album_name = localStorage.getItem("album_name");
 
    //   this.username = localStorage.getItem("username");
    this.getPhotoList();
  },
  methods: {
    getPhotoList() {
      const albumid = localStorage.getItem("album_id");;
      this.hp
        .get(`api/album/${albumid}/photos`)
        .then(data => {
            this.photoList = data
        })
        .catch(error => console.log(error));
    //   this.photoList = [
    //     {
    //       id: 1,
    //       u_id: 2,
    //       type_id: 1,
    //       photo_name: '小日子过得好呢',
    //       album_describe:
    //         '所有的人和事，自己问心无愧就好，不是你的也别强求，反正离去的，都是风景，留下的，才是人生。',
    //       photo_url:'./static/image/3.JPG',
    //       compress_url: './static/image/3.JPG'
    //     },
    //     {
    //       id: 1,
    //       u_id: 2,
    //       type_id: 1,
    //       photo_name: '小日子过得好呢',
    //       album_describe:
    //         '所有的人和事，自己问心无愧就好，不是你的也别强求，反正离去的，都是风景，留下的，才是人生。',
    //       photo_url:'./static/image/3.JPG',
    //       compress_url: './static/image/3.JPG'
    //     },
    //     {
    //       id: 1,
    //       u_id: 2,
    //       type_id: 1,
    //       photo_name: '小日子过得好呢',
    //       album_describe:
    //         '所有的人和事，自己问心无愧就好，不是你的也别强求，反正离去的，都是风景，留下的，才是人生。',
    //       photo_url:'./static/image/3.JPG',
    //       compress_url: './static/image/3.JPG'
    //     }
       
    //   ];
    },
    back(){
        this.$router.push({path:"/home"})
    }
  }
};
</script>

<style scoped>
.album-face[lazy=loading] {
  width: 100%;
  height: 160px;
  margin: auto;
}
.album-face[lazy=error] {
  width: 100%;
  height: 160px;
  margin: auto;
}
.slide-enter-active, .slide-leave-active{
transition: all 0.5s

}

.slide-enter, .slide-leave-to{
transform: translate3d(100%, 0, 0)

}
.home-container {
  height: 100%;
  flex: 1;
}
.page-title {
  background-color: #4ae087;
    margin: 0;
    height: 3rem;
    line-height: 3rem;
    font-size: 1.4rem;
    color: #f1f1f1;
    padding-left: 12px;
    text-align: left;
}
.album-container {
  display: flex;
  margin: 0.5rem 0.5rem;
  flex-wrap: wrap;
}
.album-item {
  flex-basis: 11rem;
  flex-grow: 200;
  /* height: 14rem; */
  border: 1px solid #ddd;
  margin: 0.5rem 0.5rem;
}
.plac-album {
  flex-basis: 11rem;
  flex-grow: 200;
  height: 0;
  margin: 0.5rem 0.5rem;
}
.album-face {
  width: 100%;
}
.album-name {
  margin: 0.4rem 0 0.7rem;
}
</style>
